OBJS_BOOTPACK = bootpack.obj naskfunc.obj hankaku.obj graphic.obj dsctbl.obj int.obj \
				fifo.obj keyboard.obj mouse.obj memory.obj sheet.obj timer.obj \
				mtask.obj file.obj window.obj console.obj
				
OBJS_BOOTPACK_BIN = $(bin)bootpack.obj $(bin)naskfunc.obj $(bin)hankaku.obj $(bin)graphic.obj $(bin)dsctbl.obj $(bin)int.obj \
				$(bin)fifo.obj $(bin)keyboard.obj $(bin)mouse.obj $(bin)memory.obj $(bin)sheet.obj $(bin)timer.obj \
				$(bin)mtask.obj $(bin)file.obj $(bin)window.obj $(bin)console.obj

TOOLPATH = ../z_tools/
INCPATH  = ../z_tools/haribote/

MAKE     = $(TOOLPATH)make.exe -r
NASK     = $(TOOLPATH)nask.exe
CC1      = $(TOOLPATH)cc1.exe -I$(INCPATH) -Os -Wall -quiet
GAS2NASK = $(TOOLPATH)gas2nask.exe -a
OBJ2BIM  = $(TOOLPATH)obj2bim.exe
MAKEFONT = $(TOOLPATH)makefont.exe
BIN2OBJ  = $(TOOLPATH)bin2obj.exe
BIM2HRB  = $(TOOLPATH)bim2hrb.exe
RULEFILE = $(TOOLPATH)haribote/haribote.rul
EDIMG    = $(TOOLPATH)edimg.exe
IMGTOL   = $(TOOLPATH)imgtol.com
COPY     = copy
DEL      = del
bin      = ../bin/

# 默认行为

default :
	$(MAKE) ipl20.bin
	$(MAKE) haribote.sys

# 文件生成规则

ipl20.bin : ipl20.nas Makefile
	$(NASK) ipl20.nas $(bin)ipl20.bin $(bin)ipl20.lst

asmhead.bin : asmhead.nas Makefile
	$(NASK) asmhead.nas $(bin)asmhead.bin $(bin)asmhead.lst

hankaku.bin : hankaku.txt Makefile
	$(MAKEFONT) hankaku.txt $(bin)hankaku.bin

hankaku.obj : hankaku.bin Makefile
	$(BIN2OBJ) $(bin)hankaku.bin $(bin)hankaku.obj _hankaku

bootpack.bim : $(OBJS_BOOTPACK) Makefile
	$(OBJ2BIM) @$(RULEFILE) out:$(bin)bootpack.bim stack:3136k map:$(bin)bootpack.map \
		$(OBJS_BOOTPACK_BIN)
# 3MB+64KB=3136KB

bootpack.hrb : bootpack.bim Makefile
	$(BIM2HRB) $(bin)bootpack.bim $(bin)bootpack.hrb 0

haribote.sys : asmhead.bin bootpack.hrb Makefile
	haribote_sys.bat

# 一般規則

%.gas : %.c Makefile
	$(CC1) -o $*.gas $*.c

%.nas : %.gas Makefile
	$(GAS2NASK) $*.gas $*.nas

%.obj : %.nas Makefile
	$(NASK) $*.nas $(bin)$*.obj $(bin)$*.lst